package com.tinshow.service.index.impl;

import com.tinshow.dao.article.ArticleMapper;
import com.tinshow.dao.article.XinshengMapper;
import com.tinshow.model.article.Article;
import com.tinshow.model.article.Xinsheng;
import com.tinshow.model.article.vo.ArticleVo;
import com.tinshow.model.article.vo.XinshengVo;
import com.tinshow.service.index.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by libo4 on 2017-05-07.
 */
@Service
public class ArticleServiceImpl implements ArticleService{

    @Autowired
    ArticleMapper articleMapper;
    @Autowired
    XinshengMapper xinshengMapper;

    @Override
    public List<ArticleVo> getArticleForIndex() {
        return articleMapper.getArticleForIndex();
    }

    @Override
    public List<ArticleVo> getArticleAndUser(ArticleVo articleVo) {
        return articleMapper.getArticleAndUser(articleVo);
    }

    @Override
    public ArticleVo getArticleById(Integer articleId) {
        return (ArticleVo) articleMapper.selectByPrimaryKey(articleId);
    }

    @Override
    public void insertXinsheng(Xinsheng xinsheng) {
        xinshengMapper.insertSelective(xinsheng);
    }

    @Override
    public Integer insertArticle(Article article) {
        return articleMapper.insertSelective(article);
    }

    @Override
    public List<XinshengVo> getXinshengByIndex() {
        return xinshengMapper.getXinshengByIndex();
    }
}
